#############################################################################################
#############################################################################################
#
#   Open Source License/Disclaimer, Forecast Systems Laboratory NOAA/OAR/GSD,
#   325 Broadway Boulder, CO 80305
#
#   This software is distributed under the Open Source Definition, which may be
#   found at http://www.opensource.org/.
#   In particular, redistribution and use in source and binary forms, with or
#   without modification, are permitted provided that the following conditions are met:
#
#   - Redistributions of source code must retain this notice, this list of
#     conditions and the following disclaimer.
#
#   - Redistributions in binary form must provide access to this notice, this
#     list of conditions and the following disclaimer, and the underlying source code.
#
#   - All modifications to this software must be clearly documented, and are
#     solely the responsibility of the agent making the modifications.
#
#   - If significant modifications or enhancements are made to this software,
#     the GSD Software Policy Manager (softwaremgr.fsl@noaa.gov) should be notified.
#
#   THIS SOFTWARE AND ITS DOCUMENTATION ARE IN THE PUBLIC DOMAIN AND ARE
#   FURNISHED "AS IS." THE AUTHORS, THE UNITED STATES GOVERNMENT, ITS INSTRUMENTALITIES,
#   OFFICERS, EMPLOYEES, AND AGENTS MAKE NO WARRANTY, EXPRESS OR IMPLIED, AS TO
#   THE USEFULNESS OF THE SOFTWARE AND DOCUMENTATION FOR ANY PURPOSE. THEY ASSUME
#   NO RESPONSIBILITY (1) FOR THE USE OF THE SOFTWARE AND DOCUMENTATION; OR (2) TO PROVIDE
#   TECHNICAL SUPPORT TO USERS.
#############################################################################################
#############################################################################################


import inspect
import numpy as np

class AnalysisGeneratorClass(object):
    # This serves as a template for the user of cdar to implement
    # their own analysis generation. The initial conditions and
    # parameters used in the ensemble are contained passed to the
    # analysis scheme in one array. Hence the initialization
    # conditions are treated as parameters. 

    # When the analysis is used it must MINIMALLY be passed
    # information about: 
    #                  - (ensemble size) first guess array
    #                  - (ensemble size) model simulated observation
    #                  - observation data array
    #                  - observation data error covariance
    #                  - parameter/initialization array

    # INPUT: {numpy arrays}
    #      <Data Array> = (measurement size)x(ensemble size)
    #      <Observation Data Error Covariance> = (measurement size)x(measurement size)
    #      <Ensemble First Guess Array> = (variables size)x(ensemble size)
    #      <Parameter Array> = (parameter size)x(ensemble size)
    #      <Ensemble module simulated Observation Array> = (measurement size)x(ensemble size)
    #
    # RETURN: {numpy arrays}
    #      <Analysis Array> = (variables size)x(ensemble size)
    #      <Analysis Parameter Array> = (parameter size)x(ensemble size)
    def __init__(self):
        self.Name = 'Analysis Scheme Name'

    # Returns the analysis ensemble array and the analysis parameter array.
    # AnsArray = (Ntimestep*SimulationDimension)x(EnSize) numpy array
    # AnsParamArray = (Parameter Size + Initialization Size)x(EnSize) numpy array
    def create_analysis(self,Data,DataCov,ParamArray,EnsArray,ObsArray):
        # For an example implementation look at
        # enkf*.py.
        self.ParamArray = ParamArray
        self.EnSize = ParamArray.shape[1]
        self.Data = Data
        self.DataCov = DataCov
        self.ObsArray = ObsArray
        self.EnsArray
        
        # return [AnsArray,AnsParamArray]
        raise NotImplementedError(inspect.stack()[0][3])
